<template>
  <a-card :bordered="false">
    <a-steps class="steps" :current="currentTab">
      <a-step title="填写绑定邮箱" />
      <a-step title="填写邮件验证码" />
      <a-step title="完成绑定" />
    </a-steps>
    <div class="content">
      <step1 v-if="currentTab === 0" @nextStep="nextStep" :param="param"/>
      <step2 v-if="currentTab === 1" @nextStep="nextStep" @prevStep="prevStep" :param="param"/>
      <step3 v-if="currentTab === 2" @prevStep="prevStep" @finish="finish" @close="close" :param="param"/>
    </div>
  </a-card>
</template>

<script>
  import Step1 from './Email/Step1'
  import Step2 from './Email/Step2'
  import Step3 from './Email/Step3'

  export default {
    name: "SettingsBingdingEmail",
    components: {
      Step1,
      Step2,
      Step3
    },
    data () {
      return {
        currentTab: 0,
        param: {
          mobile: ''
        }
      }
    },
    methods: {
      nextStep (data) {
        if (this.currentTab < 2) {
          this.currentTab += 1
          this.param = data
        }
      },
      prevStep (data) {
        if (this.currentTab > 0) {
          this.currentTab -= 1
          this.param = data
        }
      },
      finish () {
        this.$emit('init')
      },
      close () {
        this.$emit('close')
      }
    }
  }
</script>

<style lang="less" scoped>
  .steps {
    max-width: 750px;
    margin: 16px auto;
  }
</style>